package com.gx.mxbbx.controller;


import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.po.SysUser;
import com.gx.mxbbx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @Autowired
    private UserService userservice;

    @RequestMapping("/login")
    public String login(Integer userId, String userPassword, HttpSession session, HttpServletRequest request, Model model) {
        SysUser sysUser = userservice.findUserByUserId(userId, userPassword);
        session.setAttribute("sysUser", sysUser);
        if (sysUser != null) {

            model.addAttribute(sysUser);
            model.addAttribute("sysUser", sysUser);
            return "main";
        } else {
            return "login";
        }

    }


}
